package com.t2t.top.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class HelloController {

    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    /*
     * http://localhost:8080/hello?name=yangpengfei
     */
    @RequestMapping("/hello")
    public String greeting(@RequestParam(value = "name", required = false, defaultValue = "World") String name, Model model) {
        logger.info("hello");
        model.addAttribute("name", name);
        return "hello";
    }

    @RequestMapping("/")
    public String home() {
        logger.info("home");
        return "home";
    }

}
